package cn.wolfcode.wolf2w.redis.util;

import cn.wolfcode.wolf2w.util.Consts;
import lombok.Getter;
import org.springframework.boot.autoconfigure.cache.CacheProperties;

@Getter
public enum RedisKeys {
    USER_STRATEGY_FAVOR("user_strategy_favor",-1L),
    VISIT_TODAY("visit_today",-1L),
    STRATEGY_THUMB_UID_SID("strategy_thumb_uid_sid",-1L),
    //vokey;-1L表示没设置时间,阅读数vo的key
    STRATEGY_VO("strategy_vo",-1L),
    //短信验证码的key
    VERIFY_CODE("verify_code", Consts.VERIFY_CODE_VAI_TIME*60L),
    //token的key 30分钟
    USER_TOKEN("user_token", Consts.USER_INFO_TOKEN_VAI_TIME*60L);

    private String prefix;//key的前缀
    private Long time;//key的有效期,单位秒

    RedisKeys(String prefix, Long time) {
        this.prefix = prefix;
        this.time = time;
    }
    //拼接规则
    public String join(String... val){
        StringBuilder sb = new StringBuilder();
        sb.append(getPrefix());
        for (String s : val) {
            sb.append(":").append(s);
        }

        return sb.toString();
    }

 /* public static void main(String[] args) {
      System.out.println(RedisKeys.VERIFY_CODE.join("1","2"));
    }*/
}
